import 'package:cgvc/data/basis_http.dart';
import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';

final ArticleHttp http = ArticleHttp();

class ArticleHttp extends BasisHttp {
  //热门话题
  static const String API_TOPIC = "topic";

  static const String API_NEWS = "news";

  static const String API_TECH_NEWS = "technews";

  static const String API_BLOCK_CHAIN = "blockchain";
  @override
  void init() {
    options.baseUrl = "https://api.readhub.me/";
    interceptors
      ..add(LogInterceptor(
        requestBody: true,
        responseBody: true,
      ))
      ..add(ApiInterceptor());
  }
}

class ApiInterceptor extends InterceptorsWrapper {
  @override
  Future onRequest(RequestOptions options) async {
    LogUtil.v('---article-request--->url--> ${options.baseUrl}${options.path}' +
        ' queryParameters: ${options.queryParameters}');
    return options;
  }

  @override
  Future onResponse(Response response) {
    return super.onResponse(response);
  }
}
